home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d27 / dm310.arc / DM3PD.MNU < prev    next >
Text File  |  1990-07-22  |  2KB  |  103 lines

  1. Comment
  2. =============================================================
  3.  
  4. DM3PD.MNU Copyright 1990 by Marc Perkel
  5.  
  6. This example allows you to select a directory based on a partial
  7. name match. This example was written to work under DM3 but can be
  8. run from the command line by typing MARXMENU DM3PD.
  9.  
  10. It requires that you have PIPEDIR from the Computer Tyme DOS
  11. ToolBox, or a PIPEDIR type program that can scan your drive and
  12. output complete file names that can be redirected to a temporary
  13. file.
  14.  
  15. =============================================================
  16. EndComment
  17.  
  18. Var PickFiles SelFiles NewPath PickName SearchSt W X Y Z BoxDim
  19.  
  20. ClearScreenOnExit Off
  21.  
  22. PickName = 'C:\PD.PIC'  ;default name that Pich Directory Uses
  23.  
  24. Comment
  25. ========
  26. The default list that Pick Directory uses can be overridden by
  27. using the command SET PD.EXE=/$FileName. This next routine checks
  28. to see if this is so.
  29. ========
  30. EndComment
  31.  
  32. SearchSt = ReadEnv('PD.EXE')
  33. if SearchSt <> ''
  34.    W = pos('/$',SearchSt)
  35.    if W > 0
  36.       SearchSt = Mid(SearchSt,W + 2,255)
  37.       PickName = NextWord(SearchSt)
  38.    endif
  39. endif
  40.  
  41. ;------ If file doesn't exist, exit here.
  42. if not ExistFile(PickName) then ExitMenu
  43.  
  44. BoxBorderColor Green Brown
  45. BoxInsideColor Yellow Brown
  46. BoxHeaderColor Yellow Mag
  47.  
  48. DrawBox 31,9,44,5
  49. Writeln ' Enter partial name of the directory'
  50. Writeln ' where you want to go.
  51. Write ' > '
  52. SearchSt = UpperCase(Readln)
  53. if SearchSt = '' then ExitMenu
  54. ClearScreen
  55. TextColor Grey Brown
  56. Write ' Loading '
  57. TextColor Yellow Brown
  58. Write SearchSt
  59. TextColor Grey Brown
  60. Write ' Directories ... '
  61. TextColor Yellow Brown
  62.  
  63. ReadTextFile(PickName,PickFiles)
  64.  
  65. if NumberOfElements(PickFiles) = 0 then ExitMenu
  66.  
  67. ;------ Here we pick out the ones that match what we want.
  68.  
  69. W = 0
  70. X = 1
  71. Y = 0
  72. Z = NumberOfElements(PickFiles)
  73.  
  74. while X <= Z
  75.    if pos(SearchSt,PickFiles[X]) > 0
  76.       W = W + 1
  77.       SelFiles[W] = PickFiles[X]
  78.       Y = Max(Y,length(SelFiles[W]))
  79.    endif
  80.    X = X + 1
  81. endwhile
  82.  
  83. EraseTopWindow
  84.  
  85. if W = 0 then ExitMenu
  86.  
  87. ;------ This calculates the size and position of the pick window.
  88.  
  89. BoxDim[3] = Min(Y + 6,ScreenWidth - 6)
  90. BoxDim[4] = Min(W + 2,ScreenHeight)
  91. BoxDim[1] = Max(Min(50,ScreenWidth - BoxDim[3] - 4),1)
  92. BoxDim[2] = Max(Min(7,ScreenHeight - BoxDim[4]),1)
  93.  
  94. DrawBox BoxDim[1] BoxDim[2] BoxDim[3] BoxDim[4]
  95.  
  96. NewPath = PickOne SelFiles
  97. if NewPath = '' then ExitMenu
  98.  
  99. ;------ Change to selected directory
  100.  
  101. ChDir NewPath
  102.  
  103.